﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 菜单管理
/// </summary>
[Route("QHSESysMenu/[action]")]
[ApiController]
public class QHSEMenuController : ControllerBase
{
    private readonly QHSEMenuService _menuService;

    public QHSEMenuController(QHSEMenuService menuService)
    {
        _menuService = menuService;
    }

    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEMenuModel> menus = await _menuService.GetAsync();
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Page([FromQuery] MenuPageInputModel model)
    {
        PageResultModel<QHSEMenuModel> data = await _menuService.GetPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Add([FromBody] QHSEMenuModel model)
    {
        await _menuService.AddAsync(model);
        return AppResult.Status200OK("新增成功");
    }
}
